# encoding: utf-8
import io
import demjson

import re
from flask import json

from app.modules.menu.service import save_menu

with io.open('./menu.jsx', 'r', encoding="utf8") as _f:
    _config_content = _f.read()

    result = re.sub(r"(const menu = )([\w\W]*])(;)([\w\W]*)", "\\2",
                    _config_content)

    py_obj = demjson.decode(result)

    save_menu(py_obj)

    # print json.dumps(py_obj, indent=2, sort_keys=False, ensure_ascii=False)

    # print myjson
